package com.tyk.bookstore.front.cart.repository;

import com.tyk.bookstore.front.cart.model.dto.Cart4OrderDto;
import com.tyk.bookstore.front.cart.model.entity.CartDo;
import com.tyk.bookstore.front.common.dal.mapper.IMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author tyk
 * @description 购物车管理
 */
@Mapper
public interface CartRepository extends IMapper<CartDo> {

    /***
     * 获取选中的商品
     */
    List<Cart4OrderDto> selectCart4OrderDtoListCheckedByMemberId(@Param("memberId") Long memberId);

    void deleteCheckedByMemberId(@Param("memberId") Long memberId, @Param("bookIdList") List<Long> bookIdList);

    /**
     * 更新购物车
     */
    void updateByMemberIdAndBookId(@Param("cart") CartDo cart);

    Long existByBookId(@Param("bookId") Long bookId, @Param("memberId") Long memberId);

    Long countByBookIdList(@Param("bookIdList") List<Long> bookIdList, @Param("memberId") Long memberId);

    /**
     * 全选或全不选
     */
    void selectAllOrCancelAll(@Param("isAllSelected") Boolean isAllSelected, @Param("memberId") long memberId);

    /**
     * 查询购物车
     */
    CartDo selectCartByBookId(@Param("bookId") Long bookId, @Param("memberId")Long memberId);
}
